package com.example.bili.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.bili.R;
import com.example.bili.allbean.details_relationBean;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/3/16.
 */

public class d_abstractAdapter extends RecyclerView.Adapter<d_abstractAdapter.VHolder> {
    private Context context;
    private ArrayList<details_relationBean> relationlistbean;
    public d_abstractAdapter(Context context, ArrayList<details_relationBean> relationlistbean) {
        this.context = context;
        this.relationlistbean = relationlistbean;
    }

    @Override
    public VHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = View.inflate(context, R.layout.item_ab_recy, null);
        return new VHolder(v);
    }

    @Override
    public void onBindViewHolder(VHolder holder, int position) {
        holder.img.setImageURI(relationlistbean.get(position).getPic());
        holder.name.setText(relationlistbean.get(position).getName());
        holder.title.setText(relationlistbean.get(position).getTitle());
        holder.reply.setText("评论: "+relationlistbean.get(position).getReply());
        holder.favorite.setText("收藏: "+relationlistbean.get(position).getFavorite());
    }

    @Override
    public int getItemCount() {
        return relationlistbean.size();
    }

    public class VHolder extends RecyclerView.ViewHolder{
        SimpleDraweeView img;
        TextView name;
        TextView title;
        TextView reply;
        TextView favorite;

        public VHolder(View itemView) {
            super(itemView);
            img = (SimpleDraweeView) itemView.findViewById(R.id.item_ab_recy_img);
            name = (TextView) itemView.findViewById(R.id.item_ab_recy_name);
            title = (TextView) itemView.findViewById(R.id.item_ab_recy_title);
            reply = (TextView) itemView.findViewById(R.id.item_ab_recy_reply);
            favorite = (TextView) itemView.findViewById(R.id.item_ab_recy_favorite);
        }
    }
}
